
import chardet

# Load different encoded file to UTF8 lines


# fname: file name with full path 
def load_file_lines(fname):
    return (True, [])

# fname: file name with full path 
def load_file_content(fname):
    # TODO !!!!
    try:
        with open(fname, "rb") as fp:
            data = fp.read()
            encoding_type = chardet.detect(data)

        encode_in = encoding_type["encoding"]

        with open(fname, "r", encoding=encode_in) as fp:
            buf = fp.read(-1)
            return (True, buf)
    except BaseException as exc:
        print(exc)
        return (False, F"""File {fname} load fail! """ )
